﻿using System;

namespace MaximalSequenceOfEqualElements
{
    class MaximalSequenceOfEqualElements
    {
        static void PrintResult(int number, int times)
        {
            if (times > 1)
            {
                Console.Write("{ ");
                for (int i = 0, length = times - 1; i < length; i++)
                {
                    Console.Write("{0}, ", number);
                }
                Console.WriteLine("{0} }}", number);
            }
            else
            {
                Console.WriteLine("There is no maximum sequence.");
            }
        }
        static void MaximalSequence(int[] numbers)
        {
            int maximalLength = 1,
                currentLength = 1,
                numberHolder = 0;

            for (int index = 1, length = numbers.Length; index < length; index++)
            {
                if (numbers[index - 1] == numbers[index])
                {
                    currentLength++;
                }
                else
                {
                    if (currentLength > maximalLength)
                    {
                        maximalLength = currentLength;
                        numberHolder = numbers[index - 1];
                        currentLength = 1;
                    }
                }
            }
            if (currentLength > maximalLength)
            {
                maximalLength = currentLength;
                numberHolder = numbers[numbers.Length - 1];
            }

            PrintResult(numberHolder, maximalLength);
        }
        static void Main(string[] args)
        {
            int arrayLength;
            int[] numbers;

            Console.Write("Please enter the length of your array: ");
            arrayLength = int.Parse(Console.ReadLine());
            numbers = new int[arrayLength];
            for (int index = 0; index < arrayLength; index++)
            {
                Console.Write("Index [{0}]: ", index);
                numbers[index] = int.Parse(Console.ReadLine());
            }
            MaximalSequence(numbers);
        }
    }
}
